﻿using GraphProcessor;
using IQIGame.Onigao.Logic;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(SkillEditorConst.SkillEffective + "/" + SkillEditorConst.Package + "/" + SkillEditorConst.PackageActionCondition, typeof(SkillEditorGraph))]
    public class EffectivePackageNode_PackageActionCondition : EffectivePackageNode_Base
    {
        protected override ESkillEffectiveType actionType => ESkillEffectiveType.PackageActionCondition;

        [Input("条件")] public SkillEffectiveAction_ParamBool condition;
        [Output("true", false)] public SkillEditorActionNode trueActions;
        [Output("false", false)] public SkillEditorActionNode falseActions;

        private SkillEffectiveAction_PackageActionCondition_ConfigData _config;

        protected override void Process()
        {
            base.Process();
            this.trueActions = new SkillEditorActionNode()
            {
                setter = (x) => { (this.self.action.customConfig as SkillEffectiveAction_PackageActionCondition_ConfigData)?.trueActions.Add(x); }
            };
            this.falseActions = new SkillEditorActionNode()
            {
                setter = (x) => { (this.self.action.customConfig as SkillEffectiveAction_PackageActionCondition_ConfigData)?.falseActions.Add(x); }
            };
        }

        protected override SkillCustomConfig CreateConfig()
        {
            this._config = new SkillEffectiveAction_PackageActionCondition_ConfigData()
            {
                condition = this.condition,
                trueActions = new(),
                falseActions = new()
            };
            return this._config;
        }
    }
}